package com.clc.comm.captcha;

import com.octo.captcha.engine.CaptchaEngine;
import com.octo.captcha.engine.image.ListImageCaptchaEngine;
import com.octo.captcha.engine.image.fisheye.SimpleFishEyeEngine;
import com.octo.captcha.engine.image.gimpy.DefaultGimpyEngine;
import com.octo.captcha.engine.image.gimpy.DoubleRandomListGimpyEngine;
import com.octo.captcha.service.captchastore.CaptchaStore;
import com.octo.captcha.service.captchastore.FastHashMapCaptchaStore;
import com.octo.captcha.service.image.AbstractManageableImageCaptchaService;
import com.octo.captcha.service.image.DefaultManageableImageCaptchaService;
import com.octo.captcha.service.image.ImageCaptchaService;

/**
 * Captcha 服务,提供 创建与验证Captcha等功能
 * @author 陈列灿</br>
 * 修改时间 2012年11月24日上午10:20:38
 * modify by wuqianyu 修改验证码背景图片
 */
public class LoginImageCaptchaService extends
		AbstractManageableImageCaptchaService implements ImageCaptchaService {

	protected LoginImageCaptchaService(CaptchaStore captchaStore,
			CaptchaEngine captchaEngine, int minGuarantedStorageDelayInSeconds,
			int maxCaptchaStoreSize, int captchaStoreLoadBeforeGarbageCollection) {
		super(captchaStore, captchaEngine, minGuarantedStorageDelayInSeconds,
				maxCaptchaStoreSize, captchaStoreLoadBeforeGarbageCollection);
	}

	private static ImageCaptchaService instance;

	public static ImageCaptchaService getInstance() {
		if (instance == null) {
			// use customized engine
//			ListImageCaptchaEngine engine = new LoginListImageCaptchaEngine();
			DoubleRandomListGimpyEngine engine = new DoubleRandomListGimpyEngine();
//			DefaultGimpyEngine engine = new DefaultGimpyEngine();
//			SimpleFishEyeEngine engine = new SimpleFishEyeEngine();
			instance = new DefaultManageableImageCaptchaService(new FastHashMapCaptchaStore(), new GMailEngine(), 180,100000 , 75000); 
		}
		return instance;
	}

}